package com.iwhalecloud.citybrain.flow.platform.manager.application.service.impl.object;

import com.fasterxml.jackson.databind.JsonNode;
import com.iwhalecloud.citybrain.flow.platform.manager.application.common.context.ModelDeploymentContext;
import com.iwhalecloud.citybrain.flow.platform.manager.application.service.ModelDeploymentPostProcessor;
import com.iwhalecloud.citybrain.flow.platform.manager.common.ConstanceVariable;
import org.springframework.stereotype.Component;

/**
 * @author lich
 * @date 2021/11/15
 */
@Component
public class SaveFlowObjectMetaProcessor extends SaveObjectMetaAbstractProcessor implements
    ModelDeploymentPostProcessor {

    @Override
    public void process(ModelDeploymentContext context) {
        JsonNode modelJson = context.getModelJson();
        JsonNode propertiesNode = modelJson.get("properties");
        String flowCode = propertiesNode.get(ConstanceVariable.PROCESS_ID).asText();
        this.saveObjectMeta(modelJson, flowCode, context.getDeployId());
    }
}
